package com.starbaba.system.attach.view;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONObject;

@SuppressWarnings("serial")
public class UploadProgressServlet extends HttpServlet {
	
	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		UploadProgress progress = (UploadProgress) session.getAttribute(UploadServlet.FILE_UPLOAD_PROGRESS);
		JSONObject jsonObject = JSONObject.fromObject(progress);
		response.getWriter().print(jsonObject.toString());
	}
	
	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}
}
